package 活动安排;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] arr = new int[n][2];
        for (int i = 0; i < n; i++) {
            arr[i][0] = in.nextInt();
            arr[i][1] = in.nextInt();
        }
        Arrays.sort(arr, (t1, t2) -> {
            return t1[0] <= t2[0] ? -1 : 1;
        });
        int r = arr[0][1], res = 1;
        for (int i = 1; i < n; i++) {
            if (r <= arr[i][0]) {
                res++;
                r = arr[i][1];
            } else {
                r = Math.min(r, arr[i][1]);
            }
        }
        System.out.println(res);
    }
}
